package com.bclz.task.request;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;

public class CountMap implements WritableComparable<CountMap>  {
		
	private String website;
	private Integer count;
	
	
	public CountMap() {
	}
	
	public CountMap(String website, Integer count) {
		this.website = website;
		this.count = count;
	}



	public String getWebsite() {
		return website;
	}
	
	
	
	public void setWebsite(String website) {
		this.website = website;
	}
	
	public Integer getCount() {
		return count;
	}
	
	public void setCount(Integer count) {
		this.count = count;
	}

	@Override
	public void write(DataOutput out) throws IOException {
		// TODO Auto-generated method stub
		
		out.writeUTF(website);
		out.writeInt(count);
		
	}

	@Override
	public void readFields(DataInput in) throws IOException {
		// TODO Auto-generated method stub
		this.website=in.readUTF();
		this.count=in.readInt();
	}

	@Override
	public int compareTo(CountMap o) {
		// TODO Auto-generated method stub
		return this.count==o.getCount()?this.website.compareTo(o.website):this.count-o.getCount();
	}

	@Override
	public String toString() {
		return "website=" + website + ", count=" + count ;
	}
	
	
	
}
